#include "ChickenCase.h"
#include "Map.h"
#include "GameContext.h"

GameContext mGLevel;

ChickenCase::ChickenCase(void)
	: mScreenPosition (2)
{
}

ChickenCase::~ChickenCase(void)
{
}

void ChickenCase::Load()
{
	mSprite.Load("chickencase.png");
		int numChickens = 0;

	if (mGLevel.GetLevel() == 1)
	{
		numChickens = 4;
	}
	else
	{
		numChickens = 6;
	}

}

void ChickenCase::Unload()
{
	mSprite.Unload();
}

void ChickenCase::Update(float deltaTime)
{
	int numChickens = 4;

	const float kSpacing = 735.0f / (numChickens - 1);

	if(Input_IsKeyPressed(Keys::RIGHT))
	{
		if(mScreenPosition < numChickens)
		{
			mPosition.x += kSpacing;
			mScreenPosition++;
		}
	}
	else if(Input_IsKeyPressed(Keys::LEFT))
	{
		if(mScreenPosition > 1)
		{
			mPosition.x -= kSpacing;
			mScreenPosition--;
		}
	}
}
	
void ChickenCase::Render(const SVector2& viewOffset)
{
	const int width = mSprite.GetWidth();
	const int height = mSprite.GetHeight();
	SVector2 offset(width * 0.5f, height * 0.5f);
	SVector2 renderPosition = mPosition - offset;
	mSprite.SetPosition(renderPosition);
	mSprite.Render();
}

SRect ChickenCase::GetBoundingBox() const
{
	SRect boundingBox;
	boundingBox.min.x = mPosition.x - 64.0f;
	boundingBox.max.x = mPosition.x + 64.0f;
	return boundingBox;
}